<?php

namespace App\Policies;

use App\models\Reply;
use App\Models\User;

/**
 * 回复权限的策略
 *
 * Class ReplyPolicy
 * @package App\Policies
 */
class ReplyPolicy extends Policy
{
    /**
     * 删除权限仅是创建的人可以删除
     *
     * @param User $user
     * @param Reply $reply
     * @return bool
     */
    public function destroy(User $user, Reply $reply)
    {
        return $user->isAuthorOf($reply) || $user->isAuthorOf($reply->topic);
    }
}
